# encoding=utf-8

'''如果a+b+c=1000 且 a^2+b^2=c^2, 求a、b、c'''

import time

# start_time=time.time()
#
# for a in range(0,1001):
#     for b in range(0,1001):
#         for c in range(0,1001):
#             if a+b+c==1000 and a**2+b**2==c**2:
#                 print(a,b,c)
# end_time = time.time()
#
# print('所用时间',(end_time-start_time))

#f(n)=n*n*n*2   ；if a+b+c==1000 and a**2+b**2==c**2:当成1次； print(a,b,c)当成1次

'''优化'''

start_time1=time.time()
for a in range(1001):
    for b in range(1001):
        c=1000-a-b
        if a**2+b**2==c**2:
            print(a,b,c)
end_time1=time.time()
print('优化后所用时间:',(end_time1-start_time1))
#f(n) = n*n*3